/**
 * Created by Administrator on 2016/7/7 0007.
 */
var swiper_time;
$(document).ready(function () {
    var browser = navigator.appName;
    var b_version = navigator.appVersion;
    var version = b_version.split(";");
    var trim_Version = version[1].replace(/[ ]/g, "");
    if (browser == "Microsoft Internet Explorer" && trim_Version == "MSIE6.0") {
        home_start();
        logo_btn();
        carousel();
    }
    else if (browser == "Microsoft Internet Explorer" && trim_Version == "MSIE7.0") {
        home_start();
        logo_btn();
        carousel();
    }
    else if (browser == "Microsoft Internet Explorer" && trim_Version == "MSIE8.0") {
        home_start();
        logo_btn();
        carousel();
    } else {
        return
    }
});
function home_start() {
    $(".swiper-slide").each(function (i) {
        if (i == 0) {
            $(this).css({"display": "block"});
        } else {
            $(this).css("display", "none");
        }
    });
    $(".ie-pege-number").find("div").each(function (y) {
        if (y == 0) {
            $(this).css({"color": "#e1515b", "border-color": "#e1515b"})
        } else {
            $(this).css({"color": "#434343", "border-color": "#434343"})
        }
    });
}
function logo_btn() {
    var elem = $(".ie-pege-number").find("div");
    elem.each(function (index) {
        var obj = $(this);
        obj.click(function () {
            obj.unbind();
            clearTimeout(swiper_time);
            elem.css({"color": "#434343", "border-color": "#434343"});
            obj.css({"color": "#e1515b", "border-color": "#e1515b"});
            $(".swiper-slide").each(function (i) {
                if (i == index) {
                    $(this).css({"display": "block"});
                    logo_btn();
                    carousel();
                } else {
                    $(this).css("display", "none");
                }
            });
        });
    });
}


function carousel() {
    swiper_time = setTimeout(function () {
        $(".ie-pege-number").find("div").unbind();
        var num;
        $(".swiper-slide").each(function (index) {
            if ($(this).css("display") == "block") {
                num = index + 1;
                if (num > 2) {
                    num = 0
                }
            }
        });
        carousel_ainimate(num);
    }, 10000);
}

function carousel_ainimate(num) {
    $(".ie-pege-number").find("div").each(function (i) {
        if (i == num) {
            $(this).css({"color": "#e1515b", "border-color": "#e1515b"})
        } else {
            $(this).css({"color": "#434343", "border-color": "#434343"})
        }
    });
    $(".swiper-slide").each(function (i) {
        if (i == num) {
            $(this).css({"display": "block"});
            logo_btn();
            carousel();
        } else {
            $(this).css("display", "none");
        }
    });
}
